/*
 * Copyright (C) 2010 恒康信息科技有限公司
 * 版权所有
 */
package com.jjmmbb.dolist.ex;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.KeyEvent;
import android.widget.LinearLayout;

import com.jjmmbb.anydolist.R;

/**
 * 加载中对话框
 * 
 * @author yizhe
 * @date 2012-6-1
 */
public class DialogLoading extends Dialog {
	Context context;

	public DialogLoading(Context context, int theme) {
		super(context, theme);
		this.context = context;
		ini();
	}

	public DialogLoading(Context context) {
		super(context, R.style.HKDialog);
		this.context = context;
		ini();
	}

	void ini() {
		LinearLayout contentView = new LinearLayout(context);
		contentView.setMinimumHeight(60);
		contentView.setGravity(Gravity.CENTER);
		contentView.setOrientation(LinearLayout.HORIZONTAL);

		// 圆型进度条。
		LoadingImage loadingImage = new LoadingImage(context);

		contentView.addView(loadingImage);
		setContentView(contentView);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// 按下键盘上返回按钮
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			this.dismiss();
		}
		return true;
	}
}
